home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / chaserog.zip / SRC_ROG.ZIP / CLIENT.QC < prev    next >
Text File  |  1997-05-09  |  47KB  |  1,946 lines

  1. // updated to quake v1.06 10/8/96
  2.  
  3. // prototypes
  4. void () W_WeaponFrame;
  5. void() W_SetCurrentAmmo;
  6. void() player_pain;
  7. void() player_stand1;
  8. void (vector org) spawn_tfog;
  9. void (vector org, entity death_owner) spawn_tdeath;
  10.  
  11. void(entity targ, entity attacker) dmatch_score;
  12.  
  13. float    modelindex_eyes, modelindex_player;
  14.  
  15. /*
  16. =============================================================================
  17.  
  18.                 LEVEL CHANGING / INTERMISSION
  19.  
  20. =============================================================================
  21. */
  22.  
  23. // Rob; moved to defs.qc
  24. //float    intermission_running;
  25. //float    intermission_exittime;
  26.  
  27. /*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
  28. This is the camera point for the intermission.
  29. Use mangle instead of angle, so you can set pitch or roll as well as yaw.  'pitch roll yaw'
  30. */
  31. void() info_intermission =
  32. {
  33. };
  34.  
  35.  
  36.  
  37. void() SetChangeParms =
  38. {
  39.     if (self.health <= 0)
  40.     {
  41.         SetNewParms ();
  42.         parm14 = self.steam;    // Save the current team of the player
  43.         return;
  44.     }
  45.  
  46. // remove items
  47.     self.items = self.items - (self.items & (IT_KEY1 | IT_KEY2 |
  48.                                 IT_INVULNERABILITY | IT_SUIT |
  49.                                 IT_QUAD | IT_INVISIBILITY) );
  50.  
  51.     self.items2 = self.items2 - (self.items2 &
  52.                     (IT2_ANTIGRAV | IT2_SHIELD | IT2_SUPERHEALTH));
  53.     self.gravity = 1.0;
  54.  
  55. // cap stuff
  56.     if (self.health > 100)
  57.         self.health = 100;
  58.     if (self.health < 50)
  59.         self.health = 50;
  60.     if (self.ammo_shells1 < 25)
  61.         self.ammo_shells1 = 25;
  62.  
  63.     teamplay = cvar ( "teamplay" );
  64.     if (teamplay >= TEAM_CTF)    // don't carry items between levels in CTF
  65.         SetNewParms();
  66.     else
  67.     {
  68.         // Rob
  69.         parm2 = pack_parm( self.health, // 2
  70.                                  self.armorvalue, // 3
  71.                                  self.ammo_shells1); // 4
  72.         parm3 = pack_parm( self.ammo_nails1,  // 5
  73.                                  self.ammo_rockets1, // 6
  74.                                  self.ammo_cells1);  // 7
  75.         parm4 = pack_parm( self.ammo_lava_nails, // 11
  76.                                  self.ammo_multi_rockets, // 12
  77.                                  self.ammo_plasma);  // 13
  78.         parm1 = self.items;
  79.         // *** parm2 = self.health;
  80.         // *** parm3 = self.armorvalue;
  81.         // *** parm4 = self.ammo_shells1; // remmed below free
  82.         //parm5 = self.ammo_nails1;
  83.         //parm6 = self.ammo_rockets1;
  84.         //parm7 = self.ammo_cells1;
  85.         parm8 = self.weapon;
  86.         parm9 = self.armortype * 100;
  87.         parm10 = self.items2;
  88.         //parm11 = self.ammo_lava_nails;
  89.         //parm12 = self.ammo_multi_rockets;
  90.         //parm13 = self.ammo_plasma;
  91.     }
  92.     parm14 = self.steam; // save team setting
  93.  
  94.     // Rob;
  95.     // holds current state of cam and targeter between levels
  96.     parm5 = self.dest2_y; // cam distance
  97.     parm6 = self.dest2_z; // cam height
  98.     parm7 = self.dest2_x; // bit flags
  99.  
  100.     parm11 = self.dest1_y; // mskin pro
  101.  
  102.  
  103.  
  104. };
  105.  
  106. void() SetNewParms =
  107. {
  108.     local float p3;
  109.  
  110. //ZOID--
  111.     if (deathmatch && teamplay >= TEAM_CTF) {
  112.         parm1 = IT_SHOTGUN | IT_AXE | IT_GRAPPLE;
  113.         parm10 = IT2_ARMOR1;
  114.         p3 = 50; // Rob
  115.         parm9 = 30;
  116.     } else {
  117.         parm1 = IT_SHOTGUN | IT_AXE;
  118.         p3 = 0;   // Rob
  119.         parm9 = 0;
  120.         parm10 = 0;
  121.     }
  122. //--ZOID
  123.     //parm2 = 100;
  124.     //parm4 = 25;
  125.     //parm5 = 0;
  126.     //parm6 = 0;
  127.     //parm7 = 0;
  128.     parm8 = 1;
  129.     //parm11 = 0;
  130.     //parm12 = 0;
  131.     //parm13 = 0;
  132. //ZOID--
  133.     parm14 = -1;         // CTF: reset current team selection
  134. //--ZOID
  135.  
  136.     // Rob
  137.     parm2 = pack_parm( 100, // 2
  138.                              p3, // 3
  139.                              25); // 4
  140.     parm3 = pack_parm( 0,  // 5
  141.                              0, // 6
  142.                              0);  // 7
  143.     parm4 = pack_parm( 0, // 11
  144.                              0, // 12
  145.                              0);  // 13
  146.  
  147.     // Rob;
  148.     // only reset if zeroed  (so DM/COOP respawns don't reset)
  149.     if (! parm5) parm5 = 100; // dist - cam distance
  150.     if (! parm6) parm6 = 0.22; //zmult - cam height offset
  151.     if (! parm7)
  152.         parm7 = cvar("temp1") & (CHSCAM_ON | HUD_ON | LASERTARG_ON | LASERTARG_LIT);
  153.  
  154. };
  155.  
  156. void() DecodeLevelParms =
  157. {
  158.     if (serverflags)
  159.     {
  160.         if (world.model == "maps/start.bsp")
  161.             SetNewParms ();        // take away all stuff on starting new episode
  162.     }
  163.     if (world.model == "maps/r2m1.bsp" && !deathmatch)
  164.         SetNewParms ();
  165.     // PGM - 01/29 change to have level 8 reset all your stuff.
  166.  
  167.         // Rob
  168.         //parm2 = pack_parm( self.health, // 2
  169.         //                         self.armorvalue, // 3
  170.         //                         self.ammo_shells1); // 4
  171.         //parm3 = pack_parm( self.ammo_nails1,  // 5
  172.         //                         self.ammo_rockets1, // 6
  173.         //                         self.ammo_cells1);  // 7
  174.         //parm4 = pack_parm( self.ammo_lava_nails, // 11
  175.         //                         self.ammo_multi_rockets, // 12
  176.         //                         self.ammo_plasma);  // 13
  177.  
  178.         // Rob (get_parmbyte's)
  179.     self.items = parm1;
  180.         self.health = get_parmbyte( parm2, 1);
  181.         self.armorvalue = get_parmbyte( parm2, 2);
  182.         self.ammo_shells1 = get_parmbyte( parm2, 3);
  183.         self.ammo_nails1 = get_parmbyte( parm3, 1);
  184.         self.ammo_rockets1 = get_parmbyte( parm3, 2);
  185.         self.ammo_cells1 = get_parmbyte( parm3, 3);
  186.     // cute bug, if grapple was selected, it still will be on level change
  187.     if (parm8 == IT_GRAPPLE && teamplay < TEAM_CTF)
  188.         self.weapon = IT_AXE;
  189.     else
  190.         self.weapon = parm8;
  191.     self.armortype = parm9 * 0.01;
  192.     self.items2 = parm10;
  193.         self.ammo_lava_nails = get_parmbyte( parm4, 1);
  194.         self.ammo_multi_rockets = get_parmbyte( parm4, 2);
  195.         self.ammo_plasma = get_parmbyte( parm4, 3);
  196. //ZOID--
  197.     if (TeamColorIsLegal(parm14)) {
  198.         self.steam = parm14;
  199.         TeamSetSkin();
  200.     }
  201. //--ZOID
  202.  
  203.     // ### chasecam mod ###
  204.     if (! self.dest1_y) self.dest1_y = parm11; // mskin pro
  205.  
  206.     if (! self.dest2_y) self.dest2_y = parm5;
  207.     if (! self.dest2_z) self.dest2_z = parm6;
  208.     if (! self.dest2_x) self.dest2_x = parm7;
  209.     // sync health check variable so HUD doesn't print on startup
  210.     self.dest1_x = self.health;
  211.  
  212.  
  213. };
  214.  
  215. /*
  216. ============
  217. FindIntermission
  218.  
  219. Returns the entity to view from
  220. ============
  221. */
  222. entity() FindIntermission =
  223. {
  224.     local    entity spot;
  225.     local    float cyc;
  226.  
  227. // look for info_intermission first
  228.     spot = find (world, classname, "info_intermission");
  229.     if (spot)
  230.     {    // pick a random one
  231.         cyc = random() * 4;
  232.         while (cyc > 1)
  233.         {
  234.             spot = find (spot, classname, "info_intermission");
  235.             if (!spot)
  236.                 spot = find (spot, classname, "info_intermission");
  237.             cyc = cyc - 1;
  238.         }
  239.         return spot;
  240.     }
  241.  
  242. // then look for the start position
  243.     spot = find (world, classname, "info_player_start");
  244.     if (spot)
  245.         return spot;
  246.     
  247. // testinfo_player_start is only found in regioned levels
  248.     spot = find (world, classname, "testplayerstart");
  249.     if (spot)
  250.         return spot;
  251.     
  252.     objerror ("FindIntermission: no spot");
  253. };
  254.  
  255.  
  256. string nextmap;
  257. void() GotoNextMap =
  258. {
  259.     if (cvar("samelevel"))    // if samelevel is set, stay on same level
  260.         changelevel (mapname);
  261.     else
  262.         changelevel (nextmap);
  263. };
  264.  
  265.  
  266. void() ExitIntermission =
  267. {
  268. // skip any text in deathmatch
  269.     if (deathmatch)
  270.     {
  271.         GotoNextMap ();
  272.         return;
  273.     }
  274.     
  275.     intermission_exittime = time + 1;
  276.     intermission_running = intermission_running + 1;
  277.  
  278. //
  279. // run some text if at the end of an episode
  280. //
  281.     if (intermission_running == 2)
  282.     {
  283.         if (world.model == "maps/e1m7.bsp")
  284.         {
  285.             WriteByte (MSG_ALL, SVC_CDTRACK);
  286.             WriteByte (MSG_ALL, 2);
  287.             WriteByte (MSG_ALL, 3);
  288.             if (!cvar("registered"))
  289.             {
  290.                 WriteByte (MSG_ALL, SVC_FINALE);
  291.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task in the other three\nhaunted lands of Quake. Or are you? If\nyou don't register Quake, you'll never\nknow what awaits you in the Realm of\nBlack Magic, the Netherworld, and the\nElder World!");
  292.             }
  293.             else
  294.             {
  295.                 WriteByte (MSG_ALL, SVC_FINALE);
  296.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task. A Rune of magic\npower lies at the end of each haunted\nland of Quake. Go forth, seek the\ntotality of the four Runes!");
  297.             }
  298.             return;
  299.         }
  300.         else if (world.model == "maps/e2m6.bsp")
  301.         {
  302.             WriteByte (MSG_ALL, SVC_CDTRACK);
  303.             WriteByte (MSG_ALL, 2);
  304.             WriteByte (MSG_ALL, 3);
  305.  
  306.             WriteByte (MSG_ALL, SVC_FINALE);
  307.             WriteString (MSG_ALL, "The Rune of Black Magic throbs evilly in\nyour hand and whispers dark thoughts\ninto your brain. You learn the inmost\nlore of the Hell-Mother; Shub-Niggurath!\nYou now know that she is behind all the\nterrible plotting which has led to so\nmuch death and horror. But she is not\ninviolate! Armed with this Rune, you\nrealize that once all four Runes are\ncombined, the gate to Shub-Niggurath's\nPit will open, and you can face the\nWitch-Goddess herself in her frightful\notherworld cathedral.");
  308.             return;
  309.         }
  310.         else if (world.model == "maps/e3m6.bsp")
  311.         {
  312.             WriteByte (MSG_ALL, SVC_CDTRACK);
  313.             WriteByte (MSG_ALL, 2);
  314.             WriteByte (MSG_ALL, 3);
  315.  
  316.             WriteByte (MSG_ALL, SVC_FINALE);
  317.             WriteString (MSG_ALL, "The charred viscera of diabolic horrors\nbubble viscously as you seize the Rune\nof Hell Magic. Its heat scorches your\nhand, and its terrible secrets blight\nyour mind. Gathering the shreds of your\ncourage, you shake the devil's shackles\nfrom your soul, and become ever more\nhard and determined to destroy the\nhideous creatures whose mere existence\nthreatens the souls and psyches of all\nthe population of Earth.");
  318.             return;
  319.         }
  320.         else if (world.model == "maps/e4m7.bsp")
  321.         {
  322.             WriteByte (MSG_ALL, SVC_CDTRACK);
  323.             WriteByte (MSG_ALL, 2);
  324.             WriteByte (MSG_ALL, 3);
  325.  
  326.             WriteByte (MSG_ALL, SVC_FINALE);
  327.             WriteString (MSG_ALL, "Despite the awful might of the Elder\nWorld, you have achieved the Rune of\nElder Magic, capstone of all types of\narcane wisdom. Beyond good and evil,\nbeyond life and death, the Rune\npulsates, heavy with import. Patient and\npotent, the Elder Being Shub-Niggurath\nweaves her dire plans to clear off all\nlife from the Earth, and bring her own\nfoul offspring to our world! For all the\ndwellers in these nightmare dimensions\nare her descendants! Once all Runes of\nmagic power are united, the energy\nbehind them will blast open the Gateway\nto Shub-Niggurath, and you can travel\nthere to foil the Hell-Mother's plots\nin person.");
  328.             return;
  329.         }
  330.  
  331.         else if (world.model == "maps/r1m7.bsp")
  332.         {
  333.             WriteByte (MSG_ALL, SVC_FINALE);
  334. //-------------------------------------   end here
  335.             WriteString (MSG_ALL, "Victory! The Overlord's mangled\nremains are the evidence.  His evil\nWrath army?  Cast out to wander\naimlessly throughout time.\n\nAs the Slipgate fog surrounds you,\nthoughts rage into your consciousness:\nHas Quake's oppressive reign ended?\nIs it Salvation, or Damnation, which\nwaits beyond the Vortex?\n\nAnother thought, not quite your own,\nrazors through the haze.  \"Forgiveness\ncan yet be granted; Our Master remains\nto absolve your sins against his Chosen.\nFall down upon your knees-pray for\nQuake's mercy.\"");
  336.             return;
  337.         }
  338.         GotoNextMap();
  339.     }
  340.     
  341.     if (intermission_running == 3)
  342.     {
  343.         if (!cvar("registered"))
  344.         {    // shareware episode has been completed, go to sell screen
  345.             WriteByte (MSG_ALL, SVC_SELLSCREEN);
  346.             return;
  347.         }
  348.         
  349.         if ( (serverflags&15) == 15)
  350.         {
  351.             WriteByte (MSG_ALL, SVC_FINALE);
  352.             WriteString (MSG_ALL, 
  353. "Now, you have all four Runes. You sense\ntremendous invisible forces moving to\nunseal ancient barriers. Shub-Niggurath\nhad hoped to use the Runes Herself to\nclear off the Earth, but now instead,\nyou will use them to enter her home and\nconfront her as an avatar of avenging\nEarth-life. If you defeat her, you will\nbe remembered forever as the savior of\nthe planet. If she conquers, it will be\nas if you had never been born.");
  354.             return;
  355.         }
  356.         
  357.     }
  358.  
  359.     GotoNextMap();
  360. };
  361.  
  362. /*
  363. ============
  364. IntermissionThink
  365.  
  366. When the player presses attack or jump, change to the next level
  367. ============
  368. */
  369. void() IntermissionThink =
  370. {
  371.     if (time < intermission_exittime)
  372.         return;
  373.  
  374.     if (!self.button0 && !self.button1 && !self.button2)
  375.         return;
  376.     
  377.     ExitIntermission ();
  378. };
  379.  
  380. void() execute_changelevel =
  381. {
  382.     local entity    pos;
  383.  
  384.     intermission_running = 1;
  385.     
  386. // enforce a wait time before allowing changelevel
  387.     if (deathmatch)
  388.         intermission_exittime = time + 5;
  389.     else
  390.         intermission_exittime = time + 2;
  391.  
  392.     WriteByte (MSG_ALL, SVC_CDTRACK);
  393.     WriteByte (MSG_ALL, 3);
  394.     WriteByte (MSG_ALL, 3);
  395.     
  396.     pos = FindIntermission ();
  397.  
  398.     other = find (world, classname, "player");
  399.     while (other != world)
  400.     {
  401.         other.view_ofs = '0 0 0';
  402.         other.angles = other.v_angle = pos.mangle;
  403.         other.fixangle = TRUE;        // turn this way immediately
  404.         other.nextthink = time + 0.5;
  405.         other.takedamage = DAMAGE_NO;
  406.         other.solid = SOLID_NOT;
  407.         other.movetype = MOVETYPE_NONE;
  408.         other.modelindex = 0;
  409.         setorigin (other, pos.origin);
  410.         other = find (other, classname, "player");
  411.     }    
  412.  
  413.     WriteByte (MSG_ALL, SVC_INTERMISSION);
  414. };
  415.  
  416.  
  417. void() changelevel_touch =
  418. {
  419.     local entity    pos;
  420.  
  421.     if (other.classname != "player")
  422.         return;
  423.  
  424.     if ((cvar("noexit") == 1) || ((cvar("noexit") == 2) && (mapname != "start")))
  425.     {
  426.         T_Damage (other, self, self, 50000);
  427.         return;
  428.     }
  429.  
  430.     if (coop || deathmatch)
  431.     {
  432.         bprint (other.netname);
  433.         bprint (" exited the level\n");
  434.     }
  435.     
  436.     nextmap = self.map;
  437.  
  438.     SUB_UseTargets ();
  439.  
  440.     if ( (self.spawnflags & 1) && (deathmatch == 0) )
  441.     {    // NO_INTERMISSION
  442.         GotoNextMap();
  443.         return;
  444.     }
  445.     
  446.     self.touch = SUB_Null;
  447.  
  448. // we can't move people right now, because touch functions are called
  449. // in the middle of C movement code, so set a think time to do it
  450.     self.think = execute_changelevel;
  451.     self.nextthink = time + 0.1;
  452. };
  453.  
  454. /*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION
  455. When the player touches this, he gets sent to the map listed in the "map" variable.  Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats.
  456. */
  457. void() trigger_changelevel =
  458. {
  459.     if (!self.map)
  460.         objerror ("chagnelevel trigger doesn't have map");
  461.     
  462.     InitTrigger ();
  463.     self.touch = changelevel_touch;
  464. };
  465.  
  466.  
  467. /*
  468. =============================================================================
  469.  
  470.                 PLAYER GAME EDGE FUNCTIONS
  471.  
  472. =============================================================================
  473. */
  474.  
  475. void() set_suicide_frame;
  476.  
  477. // called by ClientKill and DeadThink
  478. void() respawn =
  479. {
  480.     if (coop)
  481.     {
  482.         // make a copy of the dead body for appearances sake
  483.         CopyToBodyQue (self);
  484.         // get the spawn parms as they were at level start
  485.         setspawnparms (self);
  486.         // respawn        
  487.         PutClientInServer ();
  488.     }
  489.     else if (deathmatch)
  490.     {
  491.         // make a copy of the dead body for appearances sake
  492.         CopyToBodyQue (self);
  493.         // set default spawn parms
  494.         SetNewParms ();
  495.         // respawn        
  496.         PutClientInServer ();
  497.         // set the skin correctly.
  498.         TeamSetSkin();
  499.     }
  500.     else
  501.     {    // restart the entire server
  502.         localcmd ("restart\n");
  503.     }
  504. };
  505.  
  506.  
  507. /*
  508. ============
  509. ClientKill
  510.  
  511. Player entered the suicide command
  512. ============
  513. */
  514. void() ClientKill =
  515. {
  516.     local entity    vSphere;
  517.  
  518. // ZOID--
  519.     if (self.suicide_count > 3)
  520.     {
  521.         sprint(self, "You have suicided too much already.\n");
  522.         return;
  523.     }
  524.     TeamDropFlagOfPlayer(self);
  525.     self.suicide_count = self.suicide_count + 1;
  526. // --ZOID
  527.  
  528.     if ( tag_token_owner == self)
  529.     {
  530.         self.health = 0;
  531.         self.solid = SOLID_NOT;
  532.         tag_token_drop();
  533.     }
  534.  
  535.     if ( self.items2 & IT2_V_SPHERE)
  536.     {
  537.         vSphere = find ( world, classname, "Vengeance");
  538.         while (vSphere)
  539.         {
  540.             if ( vSphere.owner == self )
  541.             {
  542.                 remove (vSphere);
  543.             }
  544.             vSphere = find(vSphere, classname, "Vengeance");
  545.         }
  546.     }
  547.  
  548.     bprint (self.netname);
  549.     bprint (" suicides\n");
  550.     set_suicide_frame ();
  551.     self.modelindex = modelindex_player;
  552.     self.frags = self.frags - 2;    // extra penalty
  553.     respawn ();
  554. };
  555.  
  556. float(vector v) CheckSpawnPoint =
  557. {
  558.     return FALSE;
  559. };
  560.  
  561. /*
  562. ============
  563. SelectSpawnPoint
  564.  
  565. Returns the entity to spawn at
  566. ============
  567. */
  568. entity() SelectSpawnPoint =
  569. {
  570.     local    entity    spot;
  571.     local    entity     thing;
  572.     local    float    pcount;
  573. //ZOID--
  574.     local    entity    startspot;
  575.     local    float    t;
  576. //--ZOID
  577.     
  578. // testinfo_player_start is only found in regioned levels
  579.     spot = find (world, classname, "testplayerstart");
  580.     if (spot)
  581.         return spot;
  582.         
  583. // choose a info_player_deathmatch point
  584.     if (coop)
  585.     {
  586.         lastspawn = find(lastspawn, classname, "info_player_coop");
  587.         if (lastspawn == world)
  588.             lastspawn = find (lastspawn, classname, "info_player_start");
  589.         if (lastspawn != world)
  590.             return lastspawn;
  591.     }
  592.     else if (deathmatch)
  593.     {
  594.         startspot = spot = lastspawn;
  595.         t = 0;
  596.         if (!self.ctf_killed && teamplay >= TEAM_CTF)
  597.         {
  598.             if (self.steam == TEAM1)
  599.             {
  600.                 startspot = spot = team1_lastspawn;
  601.                 t = TEAM1;
  602.             } 
  603.             else if (self.steam == TEAM2)
  604.             {
  605.                 startspot = spot = team2_lastspawn;
  606.                 t = TEAM2;
  607.             }
  608.         }
  609.         
  610.         while (1)
  611.         {
  612.             if (t == TEAM1)
  613.                 spot = find(spot, classname, "info_player_team1");
  614.             else if (t == TEAM2)
  615.                 spot = find(spot, classname, "info_player_team2");
  616.             else
  617.                 spot = find(spot, classname, "info_player_deathmatch");
  618.  
  619.             if (spot != world)
  620.             {
  621.                 if (spot == startspot)
  622.                     return startspot;
  623.                 pcount = 0;
  624.                 thing = findradius(spot.origin, 32);
  625.                 while(thing)
  626.                 {
  627.                     if (thing.classname == "player")
  628.                         pcount = pcount + 1;
  629.                     thing = thing.chain;
  630.                 }
  631.                 if (pcount == 0)
  632.                 {
  633.                     if (t == TEAM1)
  634.                         team1_lastspawn = spot;
  635.                     else if (t == TEAM2)
  636.                         team2_lastspawn = spot;
  637.                     else
  638.                         lastspawn = spot;
  639.                     return spot;
  640.                 }
  641.             }
  642.             else                
  643.                 t = 0;
  644.             // pgm fix for ctf in levels w/o ctf support
  645.         }
  646.     }
  647.  
  648.     if (serverflags)
  649.     {    // return with a rune to start
  650.         spot = find (world, classname, "info_player_start2");
  651.         if (spot)
  652.             return spot;
  653.     }
  654.     
  655.     spot = find (world, classname, "info_player_start");
  656.     if (!spot)
  657.         error ("PutClientInServer: no info_player_start on level");
  658.     
  659.     return spot;
  660. };
  661.  
  662. /*
  663. ===========
  664. PutClientInServer
  665.  
  666. called each time a player is spawned
  667. ============
  668. */
  669. void() DecodeLevelParms;
  670. void() PlayerDie;
  671.  
  672. // ### chasecam mod ###
  673. void() Chase_cam_level_start;
  674.  
  675.  
  676. void() player_touch;
  677.  
  678. void() PutClientInServer =
  679. {
  680.     local    entity spot;
  681.  
  682.     self.classname = "player";
  683.     self.health = 100;
  684.     self.takedamage = DAMAGE_AIM;
  685.     self.solid = SOLID_SLIDEBOX;
  686.     self.movetype = MOVETYPE_WALK;
  687.     self.show_hostile = 0;
  688.     self.max_health = 100;
  689.     self.flags = FL_CLIENT;
  690.     self.air_finished = time + 12;
  691.     self.dmg = 2;           // initial water damage
  692.     self.super_damage_finished = 0;
  693.     self.radsuit_finished = 0;
  694.     self.invisible_finished = 0;
  695.     self.invincible_finished = 0;
  696.     self.effects = 0;
  697.     self.invincible_time = 0;
  698.  
  699.     self.shield_finished = 0;
  700.     self.antigrav_finished = 0;
  701.  
  702. //ZOID--
  703.     self.ctf_lastreturnedflag = -10;
  704.     self.ctf_lastfraggedcarrier = -10;
  705.     self.ctf_flagsince = -10;
  706.     self.ctf_lasthurtcarrier = -10;
  707. //--ZOID
  708.  
  709.     DecodeLevelParms ();
  710.  
  711.     // spawn selection must be after DecodeLevelParms because of team stuff
  712.     spot = SelectSpawnPoint ();
  713.     
  714.     W_SetCurrentAmmo ();
  715.  
  716.     self.attack_finished = time;
  717.     self.th_pain = player_pain;
  718.     self.th_die = PlayerDie;
  719.         
  720.     self.deadflag = DEAD_NO;
  721. // paustime is set by teleporters to keep the player from moving a while
  722.     self.pausetime = 0;
  723.     
  724. //    spot = SelectSpawnPoint ();
  725.  
  726.     self.origin = spot.origin + '0 0 1';
  727.     self.angles = spot.angles;
  728.     self.fixangle = TRUE;        // turn this way immediately
  729.  
  730.     self.touch = player_touch;
  731.  
  732. // oh, this is a hack!
  733.     setmodel (self, "progs/eyes.mdl");
  734.     modelindex_eyes = self.modelindex;
  735.  
  736.     setmodel (self, "progs/player.mdl");
  737.     modelindex_player = self.modelindex;
  738.  
  739.     setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
  740.     
  741.     self.view_ofs = '0 0 22';
  742.  
  743.     player_stand1 ();
  744.     
  745.     if (deathmatch || coop)
  746.     {
  747.         makevectors(self.angles);
  748.         spawn_tfog (self.origin + v_forward*20);
  749.     }
  750.  
  751.     //Grapple stuff
  752.     self.on_hook = FALSE;
  753.     self.hook_out = FALSE;
  754.  
  755.     spawn_tdeath (self.origin, self);
  756.  
  757.     // ### chasecam mod ###
  758.     // reset view and targeter according to what was set in parm16
  759.     Chase_cam_level_start();
  760.  
  761. };
  762.  
  763.  
  764. /*
  765. =============================================================================
  766.  
  767.                 QUAKED FUNCTIONS
  768.  
  769. =============================================================================
  770. */
  771.  
  772.  
  773. /*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24)
  774. The normal starting point for a level.
  775. */
  776. void() info_player_start =
  777. {
  778. };
  779.  
  780.  
  781. /*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24)
  782. Only used on start map for the return point from an episode.
  783. */
  784. void() info_player_start2 =
  785. {
  786. };
  787.  
  788.  
  789. /*
  790. saved out by quaked in region mode
  791. */
  792. void() testplayerstart =
  793. {
  794. };
  795.  
  796. /*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24)
  797. potential spawning position for deathmatch games
  798. */
  799. void() info_player_deathmatch =
  800. {
  801.     SpawnRunes();
  802. };
  803.  
  804. /*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24)
  805. potential spawning position for coop games
  806. */
  807. void() info_player_coop =
  808. {
  809. };
  810.  
  811. /*
  812. ===============================================================================
  813.  
  814. RULES
  815.  
  816. ===============================================================================
  817. */
  818.  
  819. /*
  820. go to the next level for deathmatch
  821. */
  822. void() NextLevel =
  823. {
  824.     local entity o;
  825.  
  826.     if (mapname == "start")
  827.     {
  828. /*
  829.         if (!cvar("registered"))
  830.         {
  831.             mapname = "e1m1";
  832.         }
  833.         else if (!(serverflags & 1))
  834.         {
  835.             mapname = "e1m1";
  836.             serverflags = serverflags | 1;
  837.         }
  838.         else if (!(serverflags & 2))
  839.         {
  840.             mapname = "e2m1";
  841.             serverflags = serverflags | 2;
  842.         }
  843.         else if (!(serverflags & 4))
  844.         {
  845.             mapname = "e3m1";
  846.             serverflags = serverflags | 4;
  847.         }
  848.         else if (!(serverflags & 8))
  849.         {
  850.             mapname = "e4m1";
  851.             serverflags = serverflags - 7;
  852.         }
  853. */
  854.         // PGM 03/02/97 - make it always go to rogue level1 when in our progs
  855.         mapname = "r1m1";
  856.         o = spawn();
  857.         o.map = mapname;
  858.     }
  859.     else
  860.     {
  861.         // find a trigger changelevel
  862.         o = find(world, classname, "trigger_changelevel");
  863.  
  864.         // go back to start if no trigger_changelevel
  865.         if (!o)
  866.         {
  867.             mapname = "start";
  868.             o = spawn();
  869.             o.map = mapname;
  870.         }
  871.     }
  872.  
  873.     nextmap = o.map;
  874.     gameover = TRUE;
  875.     
  876.     if (o.nextthink < time)
  877.     {
  878.         o.think = execute_changelevel;
  879.         o.nextthink = time + 0.1;
  880.     }
  881. };
  882.  
  883. /*
  884. ============
  885. CheckRules
  886.  
  887. Exit deathmatch games upon conditions
  888. ============
  889. */
  890. void() CheckRules =
  891. {
  892.     local    float        timelimit;
  893.     local    float        fraglimit;
  894.     
  895.     if (gameover)    // someone else quit the game already
  896.         return;
  897.         
  898.     timelimit = cvar("timelimit") * 60;
  899.     fraglimit = cvar("fraglimit");
  900.     
  901.     if (timelimit && time >= timelimit)
  902.     {
  903.         NextLevel ();
  904.         return;
  905.     }
  906.     
  907.     if (fraglimit && self.frags >= fraglimit)
  908.     {
  909.         NextLevel ();
  910.         return;
  911.     }    
  912.  
  913. //ZOID--
  914.     // update team scores? 
  915.     TeamCheckUpdate();
  916. //--ZOID
  917. };
  918.  
  919. //============================================================================
  920.  
  921. void() PlayerDeathThink =
  922. {
  923.     local entity    old_self;
  924.     local float        forward;
  925.  
  926.     if ((self.flags & FL_ONGROUND))
  927.     {
  928.         forward = vlen (self.velocity);
  929.         forward = forward - 20;
  930.         if (forward <= 0)
  931.             self.velocity = '0 0 0';
  932.         else    
  933.             self.velocity = forward * normalize(self.velocity);
  934.     }
  935.  
  936. // wait for all buttons released
  937.     if (self.deadflag == DEAD_DEAD)
  938.     {
  939.         if (self.button2 || self.button1 || self.button0)
  940.             return;
  941.         self.deadflag = DEAD_RESPAWNABLE;
  942.         return;
  943.     }
  944.  
  945. // wait for any button down
  946.     if (!self.button2 && !self.button1 && !self.button0)
  947.         return;
  948.  
  949.     self.button0 = 0;
  950.     self.button1 = 0;
  951.     self.button2 = 0;
  952.     respawn();
  953. };
  954.  
  955.  
  956. void() PlayerJump =
  957. {
  958.     local vector start, end;
  959.     
  960.     if (self.flags & FL_WATERJUMP)
  961.         return;
  962.     
  963.     if (self.waterlevel >= 2)
  964.     {
  965.         if (self.watertype == CONTENT_WATER)
  966.             self.velocity_z = 100;
  967.         else if (self.watertype == CONTENT_SLIME)
  968.             self.velocity_z = 80;
  969.         else
  970.             self.velocity_z = 50;
  971.  
  972. // play swiming sound
  973.         if (self.swim_flag < time)
  974.         {
  975.             self.swim_flag = time + 1;
  976.             if (random() < 0.5)
  977.                 sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
  978.             else
  979.                 sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
  980.         }
  981.  
  982.         return;
  983.     }
  984.  
  985.     if (!(self.flags & FL_ONGROUND))
  986.         return;
  987.  
  988.     if ( !(self.flags & FL_JUMPRELEASED) )
  989.         return;        // don't pogo stick
  990.  
  991.     self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  992.  
  993.     self.flags = self.flags - FL_ONGROUND;    // don't stairwalk
  994.     
  995.     self.button2 = 0;
  996. // player jumping sound
  997.     sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
  998.     self.velocity_z = self.velocity_z + 270;
  999. };
  1000.  
  1001.  
  1002. /*
  1003. ===========
  1004. WaterMove
  1005.  
  1006. ============
  1007. */
  1008. .float    dmgtime;
  1009.  
  1010. void() WaterMove =
  1011. {
  1012. //dprint (ftos(self.waterlevel));
  1013.     if (self.movetype == MOVETYPE_NOCLIP)
  1014.         return;
  1015.     if (self.health < 0)
  1016.         return;
  1017.  
  1018.     if (self.waterlevel != 3)
  1019.     {
  1020.         if (self.air_finished < time)
  1021.             sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
  1022.         else if (self.air_finished < time + 9)
  1023.             sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
  1024.         self.air_finished = time + 12;
  1025.         self.dmg = 2;
  1026.     }
  1027.     else if (self.air_finished < time)
  1028.     {    // drown!
  1029.         if (self.pain_finished < time)
  1030.         {
  1031.             self.dmg = self.dmg + 2;
  1032.             if (self.dmg > 15)
  1033.                 self.dmg = 10;
  1034.             T_Damage (self, world, world, self.dmg);
  1035.             self.pain_finished = time + 1;
  1036.         }
  1037.     }
  1038.     
  1039.     if (!self.waterlevel)
  1040.     {
  1041.         if (self.flags & FL_INWATER)
  1042.         {    
  1043.             // play leave water sound
  1044.             sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
  1045.             self.flags = self.flags - FL_INWATER;
  1046.         }
  1047.         return;
  1048.     }
  1049.  
  1050.     if (self.watertype == CONTENT_LAVA)
  1051.     {    // do damage
  1052.         if (self.dmgtime < time)
  1053.         {
  1054.             if (self.radsuit_finished > time)
  1055.                 self.dmgtime = time + 1;
  1056.             else
  1057.                 self.dmgtime = time + 0.2;
  1058.  
  1059.             T_Damage (self, world, world, 10*self.waterlevel);
  1060.         }
  1061.     }
  1062.     else if (self.watertype == CONTENT_SLIME)
  1063.     {    // do damage
  1064.         if (self.dmgtime < time && self.radsuit_finished < time)
  1065.         {
  1066.             self.dmgtime = time + 1;
  1067.             T_Damage (self, world, world, 4*self.waterlevel);
  1068.         }
  1069.     }
  1070.     
  1071.     if ( !(self.flags & FL_INWATER) )
  1072.     {    
  1073.  
  1074. // player enter water sound
  1075.  
  1076.         if (self.watertype == CONTENT_LAVA)
  1077.             sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
  1078.         if (self.watertype == CONTENT_WATER)
  1079.             sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
  1080.         if (self.watertype == CONTENT_SLIME)
  1081.             sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
  1082.  
  1083.         self.flags = self.flags + FL_INWATER;
  1084.         self.dmgtime = 0;
  1085.     }
  1086.     
  1087.     if (! (self.flags & FL_WATERJUMP) )
  1088.         self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
  1089. };
  1090.  
  1091. void() CheckWaterJump =
  1092. {
  1093.     local vector start, end;
  1094.  
  1095. // check for a jump-out-of-water
  1096.     makevectors (self.angles);
  1097.     start = self.origin;
  1098.     start_z = start_z + 8; 
  1099.     v_forward_z = 0;
  1100.     normalize(v_forward);
  1101.     end = start + v_forward*24;
  1102.     traceline (start, end, TRUE, self);
  1103.     if (trace_fraction < 1)
  1104.     {    // solid at waist
  1105.         start_z = start_z + self.maxs_z - 8;
  1106.         end = start + v_forward*24;
  1107.         self.movedir = trace_plane_normal * -50;
  1108.         traceline (start, end, TRUE, self);
  1109.         if (trace_fraction == 1)
  1110.         {    // open at eye level
  1111.             self.flags = self.flags | FL_WATERJUMP;
  1112.             self.velocity_z = 225;
  1113.             self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  1114.             self.teleport_time = time + 2;    // safety net
  1115.             return;
  1116.         }
  1117.     }
  1118. };
  1119.  
  1120.  
  1121. /*
  1122. ================
  1123. PlayerPreThink
  1124.  
  1125. Called every frame before physics are run
  1126. ================
  1127. */
  1128. void() PlayerPreThink =
  1129. {
  1130.     local    float    mspeed, aspeed;
  1131.     local    float    r;
  1132.  
  1133.     if (intermission_running)
  1134.     {
  1135.         IntermissionThink ();    // otherwise a button could be missed between
  1136.         return;                    // the think tics
  1137.     }
  1138.         
  1139.     if (self.view_ofs == '0 0 0')
  1140.         return;        // intermission or finale
  1141.  
  1142.     if (earthquake_active)
  1143.     {
  1144.         if ( self.flags & FL_ONGROUND )
  1145.         {
  1146.             self.velocity_x = self.velocity_x + 
  1147.                                 (random() * earthquake_intensity * 2) -
  1148.                                 earthquake_intensity;
  1149.             self.velocity_y = self.velocity_y + 
  1150.                                 (random() * earthquake_intensity * 2) -
  1151.                                 earthquake_intensity;
  1152.             self.velocity_z = self.velocity_z + 
  1153.                                 (random() * earthquake_intensity * 2) -
  1154.                                 earthquake_intensity;
  1155.         }
  1156.     }
  1157.  
  1158.     makevectors (self.v_angle);        // is this still used
  1159.  
  1160. //ZOID--
  1161.     // TeamCheckLock performs all necessary teamlock checking, and performs all
  1162.     // actions needed.
  1163.     TeamCheckLock();
  1164. //--ZOID
  1165.  
  1166.     CheckMOTD();
  1167.     CheckRules ();
  1168.     WaterMove ();
  1169.  
  1170.     if (self.waterlevel == 2)
  1171.         CheckWaterJump ();
  1172.  
  1173.     if (self.deadflag >= DEAD_DEAD)
  1174.     {
  1175.         PlayerDeathThink ();
  1176.         return;
  1177.     }
  1178.     
  1179.     if (self.deadflag == DEAD_DYING)
  1180.         return;    // dying, so do nothing
  1181.  
  1182.     if (self.button2)
  1183.     {
  1184.         PlayerJump ();
  1185.     }
  1186.     else
  1187.         self.flags = self.flags | FL_JUMPRELEASED;
  1188.  
  1189. // teleporters can force a non-moving pause time    
  1190.     if (time < self.pausetime)
  1191.         self.velocity = '0 0 0';
  1192.     
  1193.     if (self.items2 & IT2_ANTIGRAV)
  1194.     {
  1195.         if ( time > self.AGping )
  1196.         {
  1197.             sound ( self, CHAN_AUTO, "belt/use.wav", 0.4, ATTN_NORM);
  1198.             self. AGping = time + 3;
  1199.             if(self. AGping >= (self.antigrav_finished - 3))
  1200.                 self. AGping = self.antigrav_finished + 3;
  1201.         }
  1202.     }
  1203.  
  1204.     RuneApplyElder(self); // regeneration rune 
  1205.  
  1206.     // Track the grapple
  1207.     if (self.hook_out)
  1208.         GrappleService();
  1209. };
  1210.     
  1211. /*
  1212. ================
  1213. CheckPowerups
  1214.  
  1215. Check for turning off powerups
  1216. ================
  1217. */
  1218. void() CheckPowerups =
  1219. {
  1220.     if (self.health <= 0)
  1221.         return;
  1222.  
  1223. // invisibility
  1224.     if (self.invisible_finished)
  1225.     {
  1226. // sound and screen flash when items starts to run out
  1227.         if (self.invisible_sound < time)
  1228.         {
  1229.             sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
  1230.             self.invisible_sound = time + ((random() * 3) + 1);
  1231.         }
  1232.  
  1233.  
  1234.         if (self.invisible_finished < time + 3)
  1235.         {
  1236.             if (self.invisible_time == 1)
  1237.             {
  1238.                 sprint (self, "Ring of Shadows magic is fading\n");
  1239.                 stuffcmd (self, "bf\n");
  1240.                 sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM);
  1241.                 self.invisible_time = time + 1;
  1242.             }
  1243.             
  1244.             if (self.invisible_time < time)
  1245.             {
  1246.                 self.invisible_time = time + 1;
  1247.                 stuffcmd (self, "bf\n");
  1248.             }
  1249.         }
  1250.  
  1251.         if (self.invisible_finished < time)
  1252.         {    // just stopped
  1253.             self.items = self.items - IT_INVISIBILITY;
  1254.             self.invisible_finished = 0;
  1255.             self.invisible_time = 0;
  1256.         }
  1257.         
  1258.     // use the eyes
  1259.         self.frame = 0;
  1260.         self.modelindex = modelindex_eyes;
  1261.     }
  1262.     else
  1263.         self.modelindex = modelindex_player;    // don't use eyes
  1264.  
  1265. // invincibility
  1266.     if (self.invincible_finished)
  1267.     {
  1268. // sound and screen flash when items starts to run out
  1269.         if (self.invincible_finished < time + 3)
  1270.         {
  1271.             if (self.invincible_time == 1)
  1272.             {
  1273.                 sprint (self, "Protection is almost burned out\n");
  1274.                 stuffcmd (self, "bf\n");
  1275.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  1276.                 self.invincible_time = time + 1;
  1277.             }
  1278.             
  1279.             if (self.invincible_time < time)
  1280.             {
  1281.                 self.invincible_time = time + 1;
  1282.                 stuffcmd (self, "bf\n");
  1283.             }
  1284.         }
  1285.         
  1286.         if (self.invincible_finished < time)
  1287.         {    // just stopped
  1288.             self.items = self.items - IT_INVULNERABILITY;
  1289.             self.invincible_time = 0;
  1290.             self.invincible_finished = 0;
  1291.         }
  1292.         if (self.invincible_finished > time)
  1293.             self.effects = self.effects | EF_DIMLIGHT;
  1294.         else
  1295.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1296.     }
  1297.  
  1298. // super damage
  1299.     if (self.super_damage_finished)
  1300.     {
  1301.  
  1302. // sound and screen flash when items starts to run out
  1303.  
  1304.         if (self.super_damage_finished < time + 3)
  1305.         {
  1306.             if (self.super_time == 1)
  1307.             {
  1308.                 sprint (self, "Quad Damage is wearing off\n");
  1309.                 stuffcmd (self, "bf\n");
  1310.                 sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
  1311.                 self.super_time = time + 1;
  1312.             }      
  1313.             
  1314.             if (self.super_time < time)
  1315.             {
  1316.                 self.super_time = time + 1;
  1317.                 stuffcmd (self, "bf\n");
  1318.             }
  1319.         }
  1320.  
  1321.         if (self.super_damage_finished < time)
  1322.         {    // just stopped
  1323.             self.items = self.items - IT_QUAD;
  1324.             self.super_damage_finished = 0;
  1325.             self.super_time = 0;
  1326.         }
  1327.         if (self.super_damage_finished > time)
  1328.             self.effects = self.effects | EF_DIMLIGHT;
  1329.         else
  1330.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1331.     }    
  1332.  
  1333. // suit    
  1334.     if (self.radsuit_finished)
  1335.     {
  1336.         self.air_finished = time + 12;        // don't drown
  1337.  
  1338. // sound and screen flash when items starts to run out
  1339.         if (self.radsuit_finished < time + 3)
  1340.         {
  1341.             if (self.rad_time == 1)
  1342.             {
  1343.                 sprint (self, "Air supply in Biosuit expiring\n");
  1344.                 stuffcmd (self, "bf\n");
  1345.                 sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM);
  1346.                 self.rad_time = time + 1;
  1347.             }
  1348.             
  1349.             if (self.rad_time < time)
  1350.             {
  1351.                 self.rad_time = time + 1;
  1352.                 stuffcmd (self, "bf\n");
  1353.             }
  1354.         }
  1355.  
  1356.         if (self.radsuit_finished < time)
  1357.         {    // just stopped
  1358.             self.items = self.items - IT_SUIT;
  1359.             self.rad_time = 0;
  1360.             self.radsuit_finished = 0;
  1361.         }
  1362.     }    
  1363.     
  1364.     if(self.shield_finished)
  1365.     {
  1366.         if ( self.shield_finished < time + 3)
  1367.         {
  1368.             if (self.shield_time == 1)
  1369.             {
  1370.                 sprint (self, "Shield failing...\n");
  1371.                 sound (self, CHAN_AUTO, "shield/fadeout.wav", 1, ATTN_NORM);
  1372.                 self.shield_time = 0;
  1373.             }
  1374.             if (self.shield_time < time)
  1375.             {
  1376.                 self.shield_time = time + 1;
  1377.                 stuffcmd (self, "bf\n");
  1378.             }
  1379.         }
  1380.         
  1381.         if ( self.shield_finished < time)
  1382.         {
  1383.             sprint (self, "Shield Lost.\n");
  1384.             self.shield_finished = 0;
  1385.             self.items2 = self.items2 - IT2_SHIELD;
  1386.         }
  1387.     }
  1388.  
  1389.     if(self.antigrav_finished)
  1390.     {
  1391.         if ( self.antigrav_finished < time + 3)
  1392.         {
  1393.             if (self.antigrav_time == 1)
  1394.             {
  1395.                 sprint (self, "Antigrav failing...\n");
  1396.                 self.antigrav_time = 0;
  1397.                 sound (self, CHAN_AUTO, "belt/fadeout.wav", 1, ATTN_NORM);
  1398.             }
  1399.             if (self.antigrav_time < time)
  1400.             {
  1401.                 self.antigrav_time = time + 1;
  1402.                 stuffcmd (self, "bf\n");
  1403.             }
  1404.         }
  1405.         
  1406.         if ( self.antigrav_finished < time)
  1407.         {
  1408.             sprint (self, "Antigrav Lost.\n");
  1409.             self.antigrav_finished = 0;
  1410.             self.items2 = self.items2 - IT2_ANTIGRAV;
  1411.             self.gravity = 1.0;
  1412.         }
  1413.     }
  1414. };
  1415.  
  1416.  
  1417. /*
  1418. ================
  1419. PlayerPostThink
  1420.  
  1421. Called every frame after physics are run
  1422. ================
  1423. */
  1424. void() xpackEnding;
  1425.  
  1426. void() PlayerPostThink =
  1427. {
  1428.     local    float    mspeed, aspeed;
  1429.     local    float    r;
  1430.  
  1431.     if (self.view_ofs == '0 0 0')
  1432.         return;        // intermission or finale
  1433.     if (self.deadflag)
  1434.         return;
  1435.  
  1436.     if (cutscene_running)
  1437.     {
  1438.         xpackEnding();
  1439.     }
  1440.  
  1441. // do weapon stuff
  1442.  
  1443.     W_WeaponFrame ();
  1444.  
  1445. // check to see if player landed and play landing sound
  1446. /*
  1447.     if ((self.jump_flag < -300) &&
  1448.             (self.flags & FL_ONGROUND) && (self.health > 0))
  1449.     {
  1450.         if (self.watertype == CONTENT_WATER)
  1451.             sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  1452.         else if (self.jump_flag < -650)
  1453.         {
  1454.             T_Damage (self, world, world, 5);
  1455.             sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  1456.             self.deathtype = "falling";
  1457.         }
  1458.         else
  1459.             sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  1460.  
  1461.         self.jump_flag = 0;
  1462.     }
  1463.  
  1464.     if (!(self.flags & FL_ONGROUND))
  1465.         self.jump_flag = self.velocity_z;
  1466. */
  1467.  
  1468.     // Rob; added more involved impact check, checks for hard impacts in
  1469.     // any given direction, and adds 'skull-cracking' check to here and
  1470.     // client obituaries (mainly usefull for hook)
  1471.     local float i1, i2;
  1472.     if (self.health > 0)
  1473.     {
  1474.         if ( vlen(self.velocity - self.finaldest) > 650)
  1475.         {
  1476.             i1 = fabs(self.velocity_x);
  1477.             i1 = i1 + fabs(self.velocity_y);
  1478.             i1 = i1 + fabs(self.velocity_z);
  1479.             i2 = fabs(self.finaldest_x);
  1480.             i2 = i2 + fabs(self.finaldest_y);
  1481.             i2 = i2 + fabs(self.finaldest_z);
  1482.  
  1483.             // was negative (avoid wind-tunnel accelerations)
  1484.             if (i1 < i2)
  1485.             {
  1486.                 // head impacts
  1487.                 if (self.finaldest_z > 500 &&
  1488.                      self.velocity_z < 10)
  1489.                 {
  1490.                     T_Damage (self, world, world, 15);
  1491.                     sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  1492.                     self.deathtype = "falling";
  1493.                     //self.deathtype = "skullcrack"; // haven't added yet
  1494.                 }
  1495.                 else
  1496.                 {
  1497.                     T_Damage (self, world, world, 5);
  1498.                     sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  1499.                     self.deathtype = "falling";
  1500.                 }
  1501.             }
  1502.         }
  1503.         else if (self.finaldest_z < -300)
  1504.         {
  1505.             // normal three-point landing
  1506.             if (self.velocity_z > -30)
  1507.                 sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  1508.         }
  1509.         self.finaldest = self.velocity;
  1510.     }
  1511.  
  1512.     CheckPowerups ();
  1513. };
  1514.  
  1515.  
  1516. /*
  1517. ===========
  1518. ClientConnect
  1519.  
  1520. called when a player connects to a server
  1521. ============
  1522. */
  1523. void() ClientConnect =
  1524. {
  1525.     bprint (self.netname);
  1526.     bprint (" entered the game\n");
  1527.     
  1528. //ZOID--
  1529.     self.suicide_count = 0;
  1530.     self.ctf_killed = 0;
  1531.  
  1532.     SetMOTD();
  1533.  
  1534.      // If this is our first connection, parm14 is < 0
  1535.      // Set lastteam negative.
  1536.      if (parm14 < 0 && teamplay > 0)
  1537.     {
  1538.         if (cvar("gamecfg") & GAMECFG_USE_COLOR)
  1539.             self.steam = self.team; // accept joining players color if legal
  1540.         else
  1541.             self.steam = -50; // always reassign
  1542.         TeamCheckLock();
  1543.     }
  1544. //--ZOID
  1545.  
  1546. // a client connecting during an intermission can cause problems
  1547.     if (intermission_running)
  1548.         ExitIntermission ();
  1549. };
  1550.  
  1551.  
  1552. /*
  1553. ===========
  1554. ClientDisconnect
  1555.  
  1556. called when a player disconnects from a server
  1557. ============
  1558. */
  1559. void() ClientDisconnect =
  1560. {
  1561.     if (gameover)
  1562.         return;
  1563.     // if the level end trigger has been activated, just return
  1564.     // since they aren't *really* leaving
  1565.  
  1566.     // let everyone else know
  1567.     bprint (self.netname);
  1568.     bprint (" left the game with ");
  1569.     bprint (ftos(self.frags));
  1570.     bprint (" frags\n");
  1571.     sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
  1572.  
  1573.     sphere_remove(self);
  1574.     if ( tag_token_owner == self)
  1575.         tag_token_drop();
  1576.     
  1577. //ZOID--
  1578.     TeamDropFlagOfPlayer(self);
  1579.     self.steam = -50;
  1580.     self.team = 0;
  1581. //--ZOID
  1582.  
  1583.     set_suicide_frame ();
  1584. };
  1585.  
  1586. /*
  1587. ===========
  1588. ClientObituary
  1589.  
  1590. called when a player dies
  1591. ============
  1592. */
  1593. void(entity targ, entity attacker) ClientObituary =
  1594. {
  1595.     local    float rnum;
  1596.     local    string deathstring, deathstring2;
  1597.     rnum = random();
  1598.  
  1599.     if (targ.classname == "player")
  1600.     {
  1601. // ZOID--
  1602.         TeamResetCarrier(targ);
  1603. // --ZOID
  1604.  
  1605.         if (attacker.classname == "teledeath")
  1606.         {
  1607.             bprint (targ.netname);
  1608.             bprint (" was telefragged by ");
  1609.             bprint (attacker.owner.netname);
  1610.             bprint ("\n");
  1611.  
  1612.             attacker.owner.frags = attacker.owner.frags + 1;
  1613.             return;
  1614.         }
  1615.  
  1616.         if (attacker.classname == "teledeath2")
  1617.         {
  1618.             bprint ("Satan's power deflects ");
  1619.             bprint (targ.netname);
  1620.             bprint ("'s telefrag\n");
  1621.  
  1622.             targ.frags = targ.frags - 1;
  1623.             return;
  1624.         }
  1625.  
  1626.         if (attacker.classname == "player")
  1627.         {
  1628.             if (targ == attacker)
  1629.             {
  1630.                 // killed self
  1631.                 attacker.frags = attacker.frags - 1;
  1632.                 bprint (targ.netname);
  1633.                 
  1634.                 if (targ.weapon == 64 && targ.waterlevel > 1)
  1635.                 {
  1636.                     bprint (" discharges into the water.\n");
  1637.                     return;
  1638.                 }
  1639.                 if (targ.weapon == IT_GRENADE_LAUNCHER)
  1640.                     bprint (" tries to put the pin back in\n");
  1641. //ZOID--
  1642. //gibbed for changing teams
  1643.                 else if (teamplay && (targ.team != targ.steam))
  1644.                 {
  1645.                     if (cvar("gamecfg") & GAMECFG_ALLOW_CHG)
  1646.                         bprint(" changed teams\n");
  1647.                     else
  1648.                         bprint(" tried to change teams\n");
  1649.                 }
  1650. //--ZOID
  1651.                 else
  1652.                     bprint (" becomes bored with life\n");
  1653.                 return;
  1654.             }
  1655.             else if ( (teamplay == 2) && (targ.team > 0)&&(targ.team == attacker.team) )
  1656.             {
  1657.                 if (rnum < 0.25)
  1658.                     deathstring = " mows down a teammate\n";
  1659.                 else if (rnum < 0.50)
  1660.                     deathstring = " checks his glasses\n";
  1661.                 else if (rnum < 0.75)
  1662.                     deathstring = " gets a frag for the other team\n";
  1663.                 else
  1664.                     deathstring = " loses another friend\n";
  1665.                 bprint (attacker.netname);
  1666.                 bprint (deathstring);
  1667.                 attacker.frags = attacker.frags - 1;
  1668.                 return;
  1669.             }
  1670.             else
  1671.             {
  1672.                 if (teamplay == TEAM_DMATCH_TAG)
  1673.                     dmatch_score (targ, attacker);
  1674.                 else
  1675.                 {
  1676.                     attacker.frags = attacker.frags + 1;
  1677. //ZOID--
  1678.                     TeamAssists(targ, attacker);
  1679. //--ZOID
  1680.                 }
  1681.  
  1682.                 rnum = attacker.weapon;
  1683.                 if (rnum == IT_AXE)
  1684.                 {
  1685.                     deathstring = " was ax-murdered by ";
  1686.                     deathstring2 = "\n";
  1687.                 }
  1688. //ZOID--
  1689.                 if (rnum == IT_GRAPPLE)
  1690.                 {
  1691.                     deathstring = " was grappled by ";
  1692.                     deathstring2 = "\n";
  1693.                 }
  1694. //--ZOID
  1695.                 if (rnum == IT_SHOTGUN)
  1696.                 {
  1697.                     deathstring = " chewed on ";
  1698.                     deathstring2 = "'s boomstick\n";
  1699.                 }
  1700.                 if (rnum == IT_SUPER_SHOTGUN)
  1701.                 {
  1702.                     deathstring = " ate 2 loads of ";
  1703.                     deathstring2 = "'s buckshot\n";
  1704.                 }
  1705.                 if (rnum == IT_NAILGUN)
  1706.                 {
  1707.                     deathstring = " was nailed by ";
  1708.                     deathstring2 = "\n";
  1709.                 }
  1710.                 if (rnum == IT_SUPER_NAILGUN)
  1711.                 {
  1712.                     deathstring = " was punctured by ";
  1713.                     deathstring2 = "\n";
  1714.                 }
  1715.                 if (rnum == IT_GRENADE_LAUNCHER)
  1716.                 {
  1717.                     deathstring = " eats ";
  1718.                     deathstring2 = "'s pineapple\n";
  1719.                     if (targ.health < -40)
  1720.                     {
  1721.                         deathstring = " was gibbed by ";
  1722.                         deathstring2 = "'s grenade\n";
  1723.                     }
  1724.                 }
  1725.                 if (rnum == IT_ROCKET_LAUNCHER)
  1726.                 {
  1727.                     deathstring = " rides ";
  1728.                     deathstring2 = "'s rocket\n";
  1729.                     if (targ.health < -40)
  1730.                     {
  1731.                         deathstring = " was gibbed by ";
  1732.                         deathstring2 = "'s rocket\n" ;
  1733.                     }
  1734.                 }
  1735.                 if (rnum == IT_LIGHTNING)
  1736.                 {
  1737.                     deathstring = " accepts ";
  1738.                     if (attacker.waterlevel > 1)
  1739.                         deathstring2 = "'s discharge\n";
  1740.                     else
  1741.                         deathstring2 = "'s shaft\n";
  1742.                 }
  1743.                 
  1744.                 if (rnum == IT_LAVA_NAILGUN ||
  1745.                         rnum == IT_LAVA_SUPER_NAILGUN)
  1746.                 {
  1747.                     deathstring = " was burned by ";
  1748.                     deathstring2 = "\n";
  1749.                 }
  1750.                 else if (rnum == IT_PLASMA_GUN)
  1751.                 {
  1752.                     deathstring = " was fused by ";
  1753.                     deathstring2 = "\n";
  1754.                 }
  1755.                 else if (rnum == IT_MULTI_GRENADE ||
  1756.                             rnum == IT_MULTI_ROCKET)
  1757.                 {
  1758.                     deathstring = " was blasted to bits by ";
  1759.                     deathstring2 = "\n";
  1760.                 }
  1761.                 
  1762.                 bprint (targ.netname);
  1763.                 bprint (deathstring);
  1764.                 bprint (attacker.netname);
  1765.                 bprint (deathstring2);
  1766.             }
  1767.             return;
  1768.         }
  1769.         else
  1770.         {
  1771.             targ.frags = targ.frags - 1;
  1772.             bprint (targ.netname);
  1773.  
  1774.             // killed by a montser?
  1775.             if (attacker.flags & FL_MONSTER)
  1776.             {
  1777.                 if (attacker.classname == "monster_army")
  1778.                     bprint (" was shot by a Grunt\n");
  1779.                 if (attacker.classname == "monster_demon1")
  1780.                     bprint (" was eviscerated by a Fiend\n");
  1781.                 if (attacker.classname == "monster_dog")
  1782.                     bprint (" was mauled by a Rottweiler\n");
  1783.                 if (attacker.classname == "monster_dragon")
  1784.                     bprint (" was annihilated by the Dragon\n");
  1785.                 if (attacker.classname == "monster_dragon_dead")
  1786.                     bprint (" was squashed by the Dragon\n");
  1787.                 if (attacker.classname == "monster_enforcer")
  1788.                     bprint (" was blasted by an Enforcer\n");
  1789.                 if (attacker.classname == "monster_fish")
  1790.                     bprint (" was fed to the Rotfish\n");
  1791.                 if (attacker.classname == "monster_hell_knight")
  1792.                     bprint (" was slain by a Death Knight\n");
  1793.                 if (attacker.classname == "monster_knight")
  1794.                     bprint (" was slashed by a Knight\n");
  1795.                 if (attacker.classname == "monster_ogre")
  1796.                     bprint (" was destroyed by an Ogre\n");
  1797.                 if (attacker.classname == "monster_oldone")
  1798.                     bprint (" became one with Shub-Niggurath\n");
  1799.                 if (attacker.classname == "monster_shalrath")
  1800.                     bprint (" was exploded by a Vore\n");
  1801.                 if (attacker.classname == "monster_shambler")
  1802.                     bprint (" was smashed by a Shambler\n");
  1803.                 if (attacker.classname == "monster_tarbaby")
  1804.                     bprint (" was slimed by a Spawn\n");
  1805.                 if (attacker.classname == "monster_vomit")
  1806.                     bprint (" was vomited on by a Vomitus\n");
  1807.                 if (attacker.classname == "monster_wizard")
  1808.                     bprint (" was scragged by a Scrag\n");
  1809.                 if (attacker.classname == "monster_zombie")
  1810.                     bprint (" joins the Zombies\n");
  1811.  
  1812.                 if (attacker.classname == "monster_eel")
  1813.                     bprint (" was electrified by an Eel\n");
  1814.                 if (attacker.classname == "monster_wrath")
  1815.                     bprint (" was disintegrated by a Wrath\n");
  1816.                 if (attacker.classname == "monster_super_wrath")
  1817.                     bprint (" was obliterated by an Overlord\n");
  1818.                 if (attacker.classname == "monster_sword")
  1819.                     bprint (" was slit open by a Phantom Swordsman\n");
  1820.                 if (attacker.classname == "monster_lava_man")
  1821.                     bprint (" fries in Hephaestus' fury\n");
  1822.                 if (attacker.classname == "monster_morph")
  1823.                     bprint (" was crushed by a Guardian\n");
  1824.                 if (attacker.classname == "monster_mummy")
  1825.                     bprint (" was Mummified\n");
  1826.  
  1827.                 return;
  1828.             }
  1829.  
  1830.             // tricks and traps
  1831.             if (attacker.classname == "explo_box")
  1832.             {
  1833.                 bprint (" blew up\n");
  1834.                 return;
  1835.             }
  1836.             if (attacker.solid == SOLID_BSP && attacker != world)
  1837.             {    
  1838.                 bprint (" was squished\n");
  1839.                 return;
  1840.             }
  1841.             if (attacker.classname == "trap_shooter" || attacker.classname == "trap_spikeshooter")
  1842.             {
  1843.                 bprint (" was spiked\n");
  1844.                 return;
  1845.             }
  1846.             if (attacker.classname == "fireball")
  1847.             {
  1848.                 bprint (" ate a lavaball\n");
  1849.                 return;
  1850.             }
  1851.             if (attacker.classname == "trigger_changelevel")
  1852.             {
  1853.                 bprint (" tried to leave\n");
  1854.                 return;
  1855.             }
  1856.  
  1857.             if (attacker.classname == "ltrail_start" || 
  1858.                 attacker.classname == "ltrail_relay")
  1859.             {
  1860.                 bprint (" rode the lightning\n");
  1861.                 return;
  1862.             }
  1863.             if (attacker.classname == "pendulum")
  1864.             {
  1865.                 bprint (" was cleaved in two\n");
  1866.                 return;
  1867.             }
  1868.             if (attacker.classname == "buzzsaw")
  1869.             {
  1870.                 bprint (" was sliced to pieces\n");
  1871.                 return;
  1872.             }
  1873.             if (attacker.classname == "plasma")
  1874.             {
  1875.                 bprint ( " was turned to plasma\n");
  1876.                 return;
  1877.             }
  1878.             if (attacker.classname == "Vengeance")
  1879.             {
  1880.                 // vengeance sphere doesn't count as a negative frag
  1881.                 targ.frags = targ.frags + 1;
  1882.                 bprint ( " was purged by the Vengeance Sphere\n");
  1883.                 return;
  1884.             }
  1885.             if (attacker.classname == "power_shield")
  1886.             {
  1887.                 // shield attacks should count for frags too..
  1888.                 // shield death doesn't count as a negative frag
  1889.                 targ.frags = targ.frags + 1;
  1890.                 attacker.owner.frags = attacker.owner.frags + 1;
  1891.                 TeamAssists(targ, attacker.owner);            //PGM
  1892.  
  1893.                 deathstring = " was smashed by ";
  1894.                 deathstring2 = "\n";
  1895.                 bprint (deathstring);
  1896.                 bprint (attacker.owner.netname);
  1897.                 bprint (deathstring2);
  1898.                 return;
  1899.             }
  1900.  
  1901.             // in-water deaths
  1902.             rnum = targ.watertype;
  1903.             if (rnum == -3)
  1904.             {
  1905.                 if (random() < 0.5)
  1906.                     bprint (" sleeps with the fishes\n");
  1907.                 else
  1908.                     bprint (" sucks it down\n");
  1909.                 return;
  1910.             }
  1911.             else if (rnum == -4)
  1912.             {
  1913.                 if (random() < 0.5)
  1914.                     bprint (" gulped a load of slime\n");
  1915.                 else
  1916.                     bprint (" can't exist on slime alone\n");
  1917.                 return;
  1918.             }
  1919.             else if (rnum == -5)
  1920.             {
  1921.                 if (targ.health < -15)
  1922.                 {
  1923.                     bprint (" burst into flames\n");
  1924.                     return;
  1925.                 }
  1926.                 if (random() < 0.5)
  1927.                     bprint (" turned into hot slag\n");
  1928.                 else
  1929.                     bprint (" visits the Volcano God\n");
  1930.                 return;
  1931.             }
  1932.  
  1933.             // fell to their death?
  1934.             if (targ.deathtype == "falling")
  1935.             {
  1936.                 targ.deathtype = "";
  1937.                 bprint (" fell to his death\n");
  1938.                 return;
  1939.             }
  1940.  
  1941.             // hell if I know; he's just dead!!!
  1942.             bprint (" died\n");
  1943.         }
  1944.     }
  1945. };
  1946.